package com.itlong.cloud.enumerate;

import java.util.Objects;

/**
 * <desc>
 *      用户设备权限来源枚举
 * </desc>
 *
 * @createDate 2017/09/30
 */
public enum DeviceAuthEnum {
    DEVICEAUTH_SMARTCARD("一卡通", 1),        //一卡通
    DEVICEAUTH_PROPERTY("物业后台", 2),        //物业后台
    DEVICEAUTH_SDK("sdk", 3),        //sdk
    DEVICEAUTH_APP("移动端App", 4),        //移动端App
    DEVICEAUTH_PROPERTY_TEMPORARY("物业后台临时", 5),        //物业后台临时
    DEVICEAUTH_HOUSEHOLD_ROLE("住户权限组", 6),        //物业后台临时

    ;

    private String description;
    private Integer type;

    /**
     * <desc>
     *      用户设备权限枚举无参构造函数
     * </desc>
     * @param
     * @return
     * @author zhangs
     * @createDate 2017/10/10
     */
    DeviceAuthEnum() {
    }

    /**
     * <desc>
     *      用户设备权限枚举描述与类型构造函数
     * </desc>
     * @param description 描述
     * @param type 类型
     * @return
     * @author zhangs
     * @createDate 2017/10/10
     */
    DeviceAuthEnum(String description, Integer type) {
        this.description = description;
        this.type = type;
    }

    /**
     * <desc>
     *      用户设备权限枚举描述
     * </desc>
     * @param
     * @return String
     * @author zhangs
     * @createDate 2017/10/10
     */
    public String getDescription() {
        return description;
    }

    /**
     * <desc>
     *      用户设备权限枚举类型
     * </desc>
     * @param
     * @return Integer
     * @author zhangs
     * @createDate 2017/10/10
     */
    public Integer getType() {
        return type;
    }

    /**
     * <desc>
     *      获取枚举的描述
     * </desc>
     * @param type 枚举类型
     * @return 枚举描述
     * @author zhangs
     * @createDate 2017/09/22
     */
    public static String getDescription(Integer type){
        DeviceAuthEnum[] types = DeviceAuthEnum.values();
        for(DeviceAuthEnum limitCategory : types ){
            if(Objects.equals(limitCategory.getType(), type)){
                return limitCategory.getDescription();
            }
        }
        return null;
    }
}
